package com.itheima.controller;

import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.common.entity.Result;
import com.itheima.pojo.CheckItem;
import com.itheima.service.ICheckItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/checkitem")
@Slf4j

/**
 * 检查项相关接口
 */
public class CheckItemController {

    @Autowired
    private ICheckItemService checkItemService;

    @PostMapping("/add")
    public Result add(@RequestBody CheckItem checkItem) {
        return checkItemService.add(checkItem);
    }

    @GetMapping("/delete")
    public Result delete(@RequestParam("id") String id) {
        return checkItemService.delete(id);
    }

    @GetMapping("/findCheckItemIdsByCheckGroupId")
    public Result findCheckItemIdsByCheckGroupId(@RequestParam("checkgroupId") String checkGroupId) {
        return checkItemService.findCheckItemIdsByCheckGroupId(checkGroupId);
    }

    @PostMapping("/edit")
    public Result edit(@RequestBody CheckItem checkItem) {
        return checkItemService.edit(checkItem);
    }

    @PostMapping("/findPage")
    public PageResult<CheckItem> findPage(@RequestBody QueryPageBean query) {
        return checkItemService.findPage(query);
    }

    @GetMapping("/findAll")
    public Result findAll() {
        return checkItemService.findAll();
    }

    @GetMapping("/findById")
    public Result findById(@RequestParam("id") String id) {
        return checkItemService.findById(id);
    }

}
